package com.ayuku.commons;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.wb.swt.SWTResourceManager;

/**
 * 
 * @author putu kusuma <putukn@gmail.com>
 *
 */
public class FormAbout extends org.eclipse.swt.widgets.Dialog {
    private Shell dialogShell;
    private Label label1;
    private Label label2;
    private Link link1;

    public FormAbout(Shell parent, int style) {
        super(parent, style);
    }

    public void open() {
        try {
            Shell parent = getParent();
            dialogShell = new Shell(parent,   SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
          
			FormLayout dialogShellLayout = new FormLayout();
            dialogShell.setLayout(dialogShellLayout);
            dialogShell.layout();
            dialogShell.pack();
            dialogShell.setSize(379, 181);
            dialogShell.setBackground(SWTResourceManager.getColor(215, 213, 253));
			{
				label2 = new Label(dialogShell, SWT.NONE);
				FormData label2LData = new FormData();
				label2LData.width = 199;
				label2LData.height = 17;
				label2LData.left =  new FormAttachment(0, 1000, 85);
				label2LData.top =  new FormAttachment(0, 1000, 58);
				label2.setLayoutData(label2LData);
				label2.setText("Developed by: putukn@gmail.com");
				label2.setAlignment(SWT.CENTER);
				label2.setBackground(SWTResourceManager.getColor(215, 213, 253));
			}
			{
				link1 = new Link(dialogShell, SWT.NONE);
				FormData link1LData = new FormData();
				link1LData.width = 131;
				link1LData.height = 23;
				link1LData.left =  new FormAttachment(0, 1000, 129);
				link1LData.top =  new FormAttachment(0, 1000, 87);
				link1.setLayoutData(link1LData);
				link1.setText("<a href=\"http://www.ayuku.com\">http://www.ayuku.com</a>\n");
				link1.setBackground(SWTResourceManager.getColor(215, 213, 253));
			}
			{
				label1 = new Label(dialogShell, SWT.NONE);
				FormData label1LData = new FormData();
				label1LData.width = 347;
				label1LData.height = 29;
				label1LData.left =  new FormAttachment(0, 1000, 12);
				label1LData.top =  new FormAttachment(0, 1000, 14);
				label1.setLayoutData(label1LData);
				label1.setText("Ayuku Simple Retail");
				label1.setAlignment(SWT.CENTER);
				label1.setFont(SWTResourceManager.getFont("Tahoma", 14, 0, false, false));
				label1.setBackground(SWTResourceManager.getColor(215, 213, 253));
			}
            //label1.setImage(SWTResourceManager.getImage("images/splash.png"));
            dialogShell.open();

            Display display = dialogShell.getDisplay();

            while (!dialogShell.isDisposed()) {
                if (!display.readAndDispatch()) {
                    display.sleep();
                }
            }
        } catch (Exception e) {
        }
    }
}
